package org.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.entity.Emp;
import org.example.mapper.EmpMapper;
import org.example.service.IEmpService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImpl extends ServiceImpl<EmpMapper, Emp> implements IEmpService {
    @Override
    public Emp login(String username, String password) {
        return this.getBaseMapper().selectEmpByUsernameAndPassword(username, password);
    }

    @Override
    public PageInfo<Emp> listByPage(Integer page, Integer limit, String empName) {
        PageHelper.startPage(page,limit);
        List<Emp> empList = this.getBaseMapper().listByName(empName);
        PageInfo<Emp> pageInfo = new PageInfo<>(empList);
        return pageInfo;
    }

    @Override
    public int add(Emp emp) {
        return this.getBaseMapper().add(emp);
    }

    @Override
    public int update(Emp emp) {
        return this.baseMapper.update(emp);
    }
}
